<?php
session_start();
//If your session isn't valid, it returns you to the login screen for protection
if(empty($_SESSION['myusername'])){
 header("location:main_login.php");
}
//echo $_SESSION['myusername'];
?>

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 <html>
 <head>
  <link href="default.css" rel="stylesheet" type="text/css" />
 <title>View Details</title>
 </head>
 <body>
 <div id="fulladmin">
 <div id='adminleft'>
 <p><center><b>Case Details</b></center></p>
 </div>
 <div id='adminright'>
 <center><h1>Mediatrix Case Information</h1><br>
 <table border='0' cellpadding='10'>

 
 <?php

  // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
	if (isset($_GET['id']) && is_numeric($_GET['id']) && $_GET['id'] > 0)
	{
 // query db
  // connect to the database
			include('connect-db.php');
			$id = $_GET['id'];
			$sql_script = "SELECT * FROM casereferred, mediator, natureofcase, judges, typeofcase WHERE casereferred.ControlNo=$id AND mediator.mediatorId=casereferred.mediatorId ";
			$sql_script .= "AND natureofcase.code=casereferred.natureOfCase AND judges.judgeId=casereferred.judgeId AND typeofcase.typeId=casereferred.typeId";

			$result = mysql_query($sql_script)
				or die(mysql_error()); 
			$row = mysql_fetch_array($result);
			
			//print_r($row);
 // check that the 'id' matches up with a row in the databse
			echo '<table border="1" cellpadding="3">';
			if($row)
			{
			    echo "<tr><td><strong>Unit Control #:</strong></td><td><strong>".$row['controlID']."</strong></td></tr>";
				echo "<tr><td><strong>Case Number:</strong></td><td><strong>".$row['CaseNo']."</strong></td></tr>";
				//echo "<tr><td>Case Title:</td><td>".$row['caseTitle']."</td></tr>";
				echo "<tr><td>Plaintiff Name:</td><td>".$row['plaintiffName']."</td></tr>";
				//echo "<tr><td>Plaintiff Lawyer:</td><td>".$row['plaintiffLawyer']."</td></tr>";
				echo "<tr><td>Defendant Name:</td><td>".$row['defendantName']."</td></tr>";
				//echo "<tr><td>Defendant Lawyer:</td><td>".$row['defendantLawyer']."</td></tr>";
				echo "<tr><td>Type of Case:</td><td>".$row['Tdescription']."</td></tr>";
				echo "<tr><td>Nature of Case:</td><td>".$row['Ndescription']."</td></tr>";
				echo "<tr><td>Case Active:</td><td>".$row['caseStatus']."</td></tr>";
				//echo "<tr><td>Date Received:</td><td>".$row['dateRegister']."</td></tr>";
				echo "<tr><td>Presiding Judge:</td><td>".$row['referringJudge']."</td></tr>";
				echo "<tr><td>Court Origin:</td><td>".$row['courtOrigin']."</td></tr>";
				echo "<tr><td>Mediator:</td><td>".$row['mediatorName']."</td></tr>";
				$case_no = $row['CaseNo'];
			}
			echo '</table><br>';
			echo  '<center><h1>Case Schedules History</h1><br>';
			echo '<table border="0" cellpadding="3">';
			
			//mysql_close($connection);
			// clear row data
			$row ='';
			//include('connect-db.php');			
			$sql_script = "SELECT * FROM schedule WHERE caseNo='".$case_no."' Order by Date DESC";
			$result = mysql_query($sql_script)
				or die(mysql_error()); 
			
			$i = 1;
			echo '<table border="1" cellpadding="3">';
			echo '<tr><th>Date</th><th>Status</th><th>Comments</th></tr>';
			
			while($row = mysql_fetch_row($result)){
			//print_r($row);
				echo '<tr><td>'.$row[2].'</td><td>'.$row[3].'</td><td>'.$row[4].'</td></tr>';
				$i++;
			}
			echo '</table>';
	}
	else
	{
	 echo '<tr><th><H2> Invalid case reference Id!</H2></th>';
	}
	
?>

</table>
</div>
<div id="adminright"><center><br><br><br><br><a href="search_frm.php?id=<?php echo $_SESSION['seedval']; ?>"><font color="red">Search again</font></a>.Return to main <a href="dashboard.php"><font color="red">Dashboard</font></a>, or you can <a href="log_out.php"><font color="red">Log Out</font></a></center></div>

 </body>
 </html> 